#ifndef DOWNLOAD_FILE_H
#define DOWNLOAD_FILE_H

#include <QObject>
#include <QTcpSocket>
#include <QFile>

class download_file : public QObject {
Q_OBJECT

public:
    explicit download_file(QObject *parent = nullptr);

    void Download(QString filename);

    /**
     * @brief recvFile 接收文件函数
     */
    void recvFile();

    void setUsername(const QString &new_username);

signals:

    //接收完毕
    void recvOver();

private slots:

private:
    QTcpSocket *file_socket;
    bool is_connected = false;

    QFile file;
    qint64 file_size = 0;//文件大小
    QString filename;

    qint64 rec_file_size = 0;//已接收大小
    bool isStart;//接收头部标记

    QString username;
};

#endif // DOWNLOAD_FILE_H
